package com.zsc.newbuds.mapper;

import java.awt.Insets;

import com.zsc.newbuds.entity.RecyclingArea;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author D
 */
public interface RecyclingAreaMapper {

    @Select("SELECT * FROM recyclingArea WHERE area_id = #{id}")
    RecyclingArea getRecyclingArea(@Param("id") int id);

    /**
     * 获取所有回收区域
     *
     * @return
     */
    @Select("select * from recyclingArea")
    List<RecyclingArea> getAreaList();

    /**
     * 增加回收区域
     *
     * @param recyclingArea
     */
    @Options(useGeneratedKeys = true, keyProperty = "areaId")
    @Insert("insert into recyclingArea(province,city,neighbourhood,add_time) values(#{province},#{city},#{neighbourhood},#{addTime})")
    void addRecyclingArea(RecyclingArea recyclingArea);

    /**
     * 更新回收区域的状态(和工作人员名字)
     *
     * @param areaId
     * @param state
     * @param times
     */
    @Update("update recyclingArea set state = #{state},recovery_times = #{times},assign_people = #{assignPeople} where area_id = #{areaId}")
    void updateRecyclingAreaState(@Param("areaId") Integer areaId, @Param("state") String state, int times, @Param("assignPeople") String assignPeople);


    /**
     * 刷新所有状态
     *
     * @param state 未分配
     */
    @Update("update recyclingArea set state = #{state}, assign_people = #{assignPeople}")
    void updateState(@Param("state") String state,@Param("assignPeople") String assignPeople);
}
